package com.ruoyi.system.service.impl;

import java.util.HashMap;
import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.system.domain.TRecor;
import com.ruoyi.system.service.ITRecorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TInventoryMapper;
import com.ruoyi.system.domain.TInventory;
import com.ruoyi.system.service.ITInventoryService;
import com.ruoyi.common.core.text.Convert;

/**
 * 库存 服务层实现
 * 
 * @author ruoyi
 * @date 2019-04-19
 */
@Service
public class TInventoryServiceImpl implements ITInventoryService 
{
	@Autowired
	private TInventoryMapper tInventoryMapper;
	@Autowired
	private ITRecorService recorService;

	/**
     * 查询库存信息
     * 
     * @param barcode 库存ID
     * @return 库存信息
     */
    @Override
	public TInventory selectTInventoryById(Long id)
	{
	    return tInventoryMapper.selectTInventoryById(id);
	}
	
	/**
     * 查询库存列表
     * 
     * @param tInventory 库存信息
     * @return 库存集合
     */
	@Override
	@DataScope(tableAlias = "tinv")
	public List<TInventory> selectTInventoryList(TInventory tInventory)
	{
	    return tInventoryMapper.selectTInventoryList(tInventory);
	}
	
    /**
     * 新增库存
     * 
     * @param tInventory 库存信息
     * @return 结果
     */
	@Override
	public int insertTInventory(TInventory tInventory)
	{
	    return tInventoryMapper.insertTInventory(tInventory);
	}
	
	/**
     * 修改库存
     * 
     * @param tInventory 库存信息
     * @return 结果
     */
	@Override
	public int updateTInventory(TInventory tInventory)
	{
	    return tInventoryMapper.updateTInventory(tInventory);
	}

	/**
     * 删除库存对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteTInventoryByIds(String ids)
	{
		return tInventoryMapper.deleteTInventoryByIds(Convert.toStrArray(ids));
	}

	@Override
	public int updateTInventoryIsstocktaking(Long deptId, String i) {
		HashMap map = new HashMap();
		map.put("deptId",deptId);
		map.put("i",i);
		tInventoryMapper.updateTInventoryIsstocktaking(map);
		return 1;
	}

	@Override
	public List<TInventory> selectTInventoryByCode(String barcode) {
		return tInventoryMapper.selectTInventoryByCode(barcode);
	}

}
